// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.jasmin.unit.z80.v3;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public interface Constants {
  public static final int XY_MODE_HL = 0x0;
  public static final int XY_MODE_IX = 0x1;
  public static final int XY_MODE_IY = 0x2;  
  
  public static final int DATA_IN_REG_B    = 0x0;
  public static final int DATA_IN_REG_C    = 0x1;
  public static final int DATA_IN_REG_D    = 0x2;
  public static final int DATA_IN_REG_E    = 0x3;
  public static final int DATA_IN_REG_XYh  = 0x4;
  public static final int DATA_IN_REG_XYl  = 0x5;
  public static final int DATA_IN_REG_F    = 0x6;
  public static final int DATA_IN_REG_A    = 0x7;
  public static final int DATA_IN_REG_I    = 0x8;
  public static final int DATA_IN_REG_R    = 0x9;
  public static final int DATA_IN_REG_W    = 0xA;
  public static final int DATA_IN_REG_Z    = 0xB;
  public static final int DATA_IN_ALU      = 0xC;
  public static final int DATA_IN_REG_TMP  = 0xE;
  public static final int DATA_IN_DATA     = 0xF;
  public static final int DATA_IN_ZERO     = 0x10;
  
  public static final int DATA_OUT_REG_B   = 0x0;
  public static final int DATA_OUT_REG_C   = 0x1;
  public static final int DATA_OUT_REG_D   = 0x2;
  public static final int DATA_OUT_REG_E   = 0x3;
  public static final int DATA_OUT_REG_XYh = 0x4;
  public static final int DATA_OUT_REG_XYl = 0x5;
  public static final int DATA_OUT_REG_F   = 0x6;
  public static final int DATA_OUT_REG_A   = 0x7;
  public static final int DATA_OUT_REG_I   = 0x8;
  public static final int DATA_OUT_REG_R   = 0x9;
  public static final int DATA_OUT_REG_W   = 0xA;
  public static final int DATA_OUT_REG_Z   = 0xB;
  public static final int DATA_OUT_REG_TMP = 0xC;
  public static final int DATA_OUT_OPCODE  = 0xD;
  public static final int DATA_OUT_BUFFER  = 0xE;
  public static final int DATA_OUT_NONE    = 0xF;
  public static final int DATA_OUT_REG_TMP_ACC = 0x10;
  
  public static final int ADDR_IN_REG_BC     = 0x0;
  public static final int ADDR_IN_REG_DE     = 0x1;
  public static final int ADDR_IN_REG_HL     = 0x2;
  public static final int ADDR_IN_REG_SP     = 0x3;
  public static final int ADDR_IN_REG_PC     = 0x4;
  public static final int ADDR_IN_REG_WZ     = 0x5;
  public static final int ADDR_IN_REG_IR     = 0x6;
  public static final int ADDR_IN_REG_TMP    = 0x7;
  public static final int ADDR_IN_ZERO       = 0xF;
  
  public static final int ADDR_OUT_REG_BC      = 0x0;
  public static final int ADDR_OUT_REG_DE      = 0x1;
  public static final int ADDR_OUT_REG_HL      = 0x2;
  public static final int ADDR_OUT_REG_SP      = 0x3;
  public static final int ADDR_OUT_REG_PC      = 0x4;
  public static final int ADDR_OUT_REG_WZ      = 0x5;
  public static final int ADDR_OUT_REG_TMP     = 0x6;
  public static final int ADDR_OUT_BUFFER      = 0x8;
  public static final int ADDR_OUT_NONE        = 0xF;
  
  public static final int ADDR_INC_MODE_NONE = 0x0;
  public static final int ADDR_INC_MODE_INC  = 0x1;
  public static final int ADDR_INC_MODE_DEC  = 0x2;
  
  public static final int ADDR_BUFFER_IN_PC  = 0x0;
  public static final int ADDR_BUFFER_IN_HL  = 0x1;
  public static final int ADDR_BUFFER_IN_SP  = 0x2;
  public static final int ADDR_BUFFER_IN_WZ  = 0x3;
  
  public static final int INSTR_SET_BASE = 0x00;
  public static final int INSTR_SET_CB   = 0x01;
  public static final int INSTR_SET_ED   = 0x02;
  
  public static final int ALU_ADD = 0x00; 
  public static final int ALU_ADC = 0x01; 
  public static final int ALU_SUB = 0x02; 
  public static final int ALU_SBC = 0x03; 
  public static final int ALU_AND = 0x04; 
  public static final int ALU_OR  = 0x05; 
  public static final int ALU_XOR = 0x06; 
  public static final int ALU_CP  = 0x07;
  
  public static final int FLAGS_S  = 0x80;
  public static final int FLAGS_Z  = 0x40;
  public static final int FLAGS_X  = 0x20;
  public static final int FLAGS_H  = 0x10;
  public static final int FLAGS_Y  = 0x08;
  public static final int FLAGS_PV = 0x04;
  public static final int FLAGS_N  = 0x02;
  public static final int FLAGS_C  = 0x01;
  
  
  // 8-bit load group
  public static final int MOP_LD_r_r     = 0x00;
  public static final int MOP_LD_r_n     = 0x01;
  public static final int MOP_LD_r_iHL   = 0x02;
  public static final int MOP_LD_iHL_r   = 0x03;
  public static final int MOP_LD_iHL_n   = 0x04;
  public static final int MOP_LD_A_idd   = 0x05;
  public static final int MOP_LD_A_inn   = 0x06;
  public static final int MOP_LD_idd_A   = 0x07;
  public static final int MOP_LD_inn_A   = 0x4B;
  public static final int MOP_LD_A_I     = 0x08;
  public static final int MOP_LD_A_R     = 0x09;
  public static final int MOP_LD_I_A     = 0x0A;
  public static final int MOP_LD_R_A     = 0x0B;
  
  // 16-bit load group
  public static final int MOP_LD_dd_nn   = 0x0C;
  public static final int MOP_LD_dd_inn  = 0x0E;
  public static final int MOP_LD_inn_dd  = 0x10;
  public static final int MOP_LD_SP_HL   = 0x11;
  public static final int MOP_PUSH_qq    = 0x12;
  public static final int MOP_POP_qq     = 0x13;
  
  // Exchange, Blobk Transfer and Search Group
  public static final int MOP_EX_DE_HL   = 0x14;
  public static final int MOP_EX_AF_AF2  = 0x15;
  public static final int MOP_EXX        = 0x16;
  public static final int MOP_EX_iSP_HL  = 0x17;
  public static final int MOP_LDxx       = 0x18; // LDI, LDIR, LDD, LDDR
  public static final int MOP_CPxx       = 0x19; // CPI, CPIR, CPD, CPDR
  
  // 8-bit Arithmetic group
  public static final int MOP_ALU_r      = 0x1A; // ADD, ADC, SUB, SBC, AND, OR, XOR, CP
  public static final int MOP_ALU_n      = 0x1B; // ADD, ADC, SUB, SBC, AND, OR, XOR, CP
  public static final int MOP_ALU_iHL    = 0x1C; // ADD, ADC, SUB, SBC, AND, OR, XOR, CP
  public static final int MOP_INC_r      = 0x1D;
  public static final int MOP_INC_iHL    = 0x1E;
  public static final int MOP_DEC_r      = 0x1F;
  public static final int MOP_DEC_iHL    = 0x20;
  
  // General Purpose Arithmetic and CPU control
  public static final int MOP_DAA     = 0x21;
  public static final int MOP_CPL     = 0x22;
  public static final int MOP_NEG     = 0x23;
  public static final int MOP_CCF     = 0x24;
  public static final int MOP_SCF     = 0x25;
  public static final int MOP_NOP     = 0x26;
  public static final int MOP_HALT    = 0x27;
  public static final int MOP_DI      = 0x28;
  public static final int MOP_EI      = 0x29;
  public static final int MOP_IM_0    = 0x2A;
  public static final int MOP_IM_1    = 0x2B;
  public static final int MOP_IM_2    = 0x2C;
  
  // Rotate and Shift Group
  public static final int MOP_ROT_A     = 0x2D; // RLCA, RLA, RRCA, RRA
  public static final int MOP_ROTSH_r   = 0x2E; // RLC, RL, RRC, RR, SLA, SRA, SLL, SRL
  public static final int MOP_ROTSH_iHL = 0x2F;
  public static final int MOP_RLD       = 0x30;
  public static final int MOP_RRD       = 0x31;

  // Bit Set, Reset and Test
  public static final int MOP_BIT_b_r   = 0x32;
  public static final int MOP_BIT_b_iHL = 0x33;
  public static final int MOP_SET_b_r   = 0x34;
  public static final int MOP_SET_b_iHL = 0x35;
  public static final int MOP_RES_b_r   = 0x36;
  public static final int MOP_RES_b_iHL = 0x37;

  // Jump
  public static final int MOP_JP_nn     = 0x38;
  public static final int MOP_JP_cc_nn  = 0x39;
  public static final int MOP_JR_e      = 0x3A;
  public static final int MOP_JR_cc_e   = 0x3B;
  public static final int MOP_JP_HL     = 0x3C;
  public static final int MOP_DJNZ_e    = 0x3D;
  
  // Call and return
  public static final int MOP_CALL_nn    = 0x3E;
  public static final int MOP_CALL_cc_nn = 0x3F;
  public static final int MOP_RET        = 0x40;
  public static final int MOP_RET_cc     = 0x41;
  public static final int MOP_RETI       = 0x42;
  public static final int MOP_RETN       = 0x43;
  public static final int MOP_RST_p      = 0x44;

  // Input and Output
  public static final int MOP_IN_A_n     = 0x45;
  public static final int MOP_IN_r_BC    = 0x46;
  public static final int MOP_OUT_n_A    = 0x47;
  public static final int MOP_OUT_BC_r   = 0x48;
  public static final int MOP_INxx       = 0x49; // INI, INIR, IND, INDR
  public static final int MOP_OUTxx      = 0x4A; // OUTI, OTIR, OUTD, OTDR
  
  public static final int MOP_PREFIX_CB  = 0x4C;
  public static final int MOP_PREFIX_DD  = 0x4D;
  public static final int MOP_PREFIX_ED  = 0x4E;
  public static final int MOP_PREFIX_FD  = 0x4F;
  
  public static final int CC_NZ = 0x00;
  public static final int CC_Z  = 0x01;
  public static final int CC_NC = 0x02;
  public static final int CC_C  = 0x03;
  public static final int CC_PO = 0x04;
  public static final int CC_PE = 0x05;
  public static final int CC_P  = 0x06;
  public static final int CC_M  = 0x07;
}
